﻿using System;
using System.Collections.Generic;
using System.Text;
using T.FAS.Runtime.Base.Common;
using T.FAS.Runtime.Base.Dao;
using T.FAS.Runtime.Base.Entity;

namespace T.FAS.Runtime.Base.Service
{
    public class FasTenantConfigService
    {
        private static FasTenantConfigService instance;

        private static readonly object syncObj = new object();

        private List<FASTenantConfig> fASTenantConfiglist = null;
        private FasTenantConfigService()
        {
            fASTenantConfiglist = new FASTenantConfigDao().GetFASTenantConfig();
        }
        public static FasTenantConfigService GetInstance()
        {
            if (instance == null)
            {
                lock (syncObj)
                {
                    if (instance == null)
                    {
                        instance = new FasTenantConfigService();
                    }
                }
            }

            return instance;
        }
        public FASTenantConfig GetFasTenantConfig()
        {
            FASTenantConfig fASTenantConfig = null;
            string tenantID = UserUtil.GetCurrentUserTenantId();
            if (fASTenantConfiglist != null)
            {
                fASTenantConfig = fASTenantConfiglist.Find(item=>item.TenantID == tenantID);
            }
            return fASTenantConfig;
        }
    }
}
